class_name Stats
extends Node

signal energy_shield_changed
signal structural_strength_changed
signal energy_changed

##最大护盾能量
@export var max_energy_shield: float = 100.0
##最大结构强度
@export var max_structural_strength: float = 100.0
##最大电池容量
@export var max_energy: float = 100.0
##射击冷却时间
@export var shot_wait_time: float = 0.2
##跃迁冷却时间
@export var transmit_wait_time: float = 0.5
##飞行速度
@export var running_speed: float = 200.0
##跃迁速度
@export var transmit_speed: float = 256.0
##跃迁持续时间
@export var transmit_duration: float = 0.3
##跃迁消耗电池容量
@export var transmit_cost: float = 20.0
##攻击力
@export var attack_damage: float = 20.0
##防御力
@export var defensive_power: float = 0.0

##护盾能量恢复速度
@export var energy_shield_regen: float = 8.0
##结构强度恢复速度
@export var structural_strength_regen: float = 0.0
##电池能量恢复速度
@export var energy_regen: float = 8.0

@onready var energy_shield: float = max_energy_shield:
	set(value):
		value = clamp(value, 0, max_energy_shield)
		if energy_shield == value:
			return
		energy_shield = value
		energy_shield_changed.emit()

@onready var structural_strength: float = max_structural_strength:
	set(value):
		value = clamp(value, 0, max_structural_strength)
		if structural_strength == value:
			return
		structural_strength = value
		structural_strength_changed.emit()

@onready var energy: float = max_energy:
	set(value):
		value = clamp(value, 0, max_energy)
		if energy == value:
			return
		energy = value
		energy_changed.emit()

func _process(delta: float) -> void:
	energy_shield += energy_shield_regen * delta
	structural_strength += structural_strength_regen * delta
	energy += energy_regen * delta

#func to_dict() -> Dictionary:
	#return {
		#max_energy = max_energy,
		#max_health = max_health,
		#health = health,
	#}
#
#func from_dict(dict: Dictionary) -> void:
	#max_energy = dict.max_energy
	#max_health = dict.max_health
	#health = dict.health
